﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Dto;
using MyMES.Infrastructure;
using MyMES.IServices;
using MyMES.Services;
using System.Threading.Tasks;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers
{
    /// <summary>
    /// 设备管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EquipmentManagementController : ControllerBase
    {
        /// <summary>
        /// 点检记录仓储
        /// </summary>
        private readonly IRecordsinspectionsService _irecordsinspectionsService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="supplierService">供应商仓储</param>
        public EquipmentManagementController(IRecordsinspectionsService irecordsinspectionsService)
        {
            _irecordsinspectionsService = irecordsinspectionsService;
        }

        /// <summary>
        /// 获取点检记录数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPage<Recordsinspections>> GetRecordsinspectionsList([FromQuery] GetRecordsinspectionsListDTO request)
        {
            return await _irecordsinspectionsService.GetRecordsinspectionsList(request);
        }

        /// <summary>
        /// 新增点检记录
        /// </summary>
        /// <param name="param">点检记录参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateRecordsinspections([FromBody] Recordsinspections param)
        {
            return await _irecordsinspectionsService.CreateRecordsinspections(param);
        }

        /// <summary>
        /// 删除点检记录
        /// </summary>
        /// <param name="param">点检记录参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> DeleteRecordsinspections([FromBody] Recordsinspections param)
        {
            return await _irecordsinspectionsService.DeleteRecordsinspections(param);
        }

        /// <summary>
        /// 修改点检记录
        /// </summary>
        /// <param name="param">点检记录参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateRecordsinspections([FromBody] Recordsinspections param)
        {
            return await _irecordsinspectionsService.UpdateRecordsinspections(param);
        }
    }
}
